package com.self.oss.controller;

import com.self.commonutils.R;
import com.self.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Api(description = "阿里云对象存储OSS")
@CrossOrigin
@RestController
@RequestMapping("/eduoss/fileoss")
public class OssController {

    @Autowired
    private OssService ossService;


    @ApiOperation(value = "上传讲师头像")
    @PostMapping("upload")
    public R upload(
            @ApiParam(name = "file",value = "头像",required = true)
            @RequestParam("file") MultipartFile file){

        System.out.println("进入");
        String uploadUrl = ossService.uploadAvatar(file);
        System.out.println("进入进入");
        return R.ok().data("uploadUrl",uploadUrl);
    }

}
